// 防抖
export function debounce(fn, wait = 30) {
  var timeout = null;
  return function () {
    if (timeout !== null) clearTimeout(timeout);
    timeout = setTimeout(fn, wait);
  };
}
// 节流
export function throttle(func, delay = 30) {
  var prev = Date.now();
  return function () {

    var context = this;
    var args = arguments;
    var now = Date.now();
    if (now - prev >= delay) {
      func.apply(context, args);
      prev = Date.now();
    }
  };
}

export default {
  debounce,
  throttle
}